#!/usr/bin/env bash

BLD=$(tput bold)
GRY="\e[90m"


TOOLCHAIN=`pwd`/node_modules/nodeos-cross-toolchain

source $TOOLCHAIN/scripts/adjustEnvVars.sh || exit $?


(
  cd node_modules/nodeos-barebones &&
  npm run dockerBuild              || exit 10
) &&
(
  cd node_modules/nodeos-initramfs &&
  npm run dockerBuild              || exit 20
) &&
(
  cd node_modules/nodeos-rootfs    &&
  npm run dockerBuild              || exit 30
) &&
(
  docker build -t nodeos .         || exit 40
) || exit $?


echo -e "${GRY}------------------------------------------${CLR}"
echo -e "${GRN}${BLD}Success!${CLR}"
echo -e "${GRN}You just registered a custom NodeOS image${CLR}"
echo -e "${GRY}------------------------------------------${CLR}"
echo
echo -e "- Interactively run your image with:"

echo -e "${WHT}    npm run docker${CLR}"
echo
echo -e "- Share your creation with:"
echo -e "${WHT}    docker push NodeOS${CLR}"
